<?php
/**
 * @package Autogenerator for Joomla!
 * @version 3.0.0
 * @author Truong Cong Duc <truongcongduc4@gmail.com>
 * @link autogenerator.blogspot.com
 * @copyright (c) 2013, Truong Cong Duc
 * @license GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

class AutogeneratorControllerMvcs extends JControllerAdmin {

    /**
     *
     * @var AutogeneratorModelMvc
     */
    public $oModelMvc;

    public function __construct($arConfig = array()) {
        parent::__construct($arConfig);

        $this->oModelMvc = $this->getModel();
    }

    public function getModel($strName = 'Mvc', $strPrefix = 'AutogeneratorModel', $arConfig = array('ignore_request' => true)) {
        return parent::getModel($strName, $strPrefix, $arConfig);
    }

    public function saveOrderAjax() {
        $pks = $this->input->post->get('cid', array(), 'array');
        $order = $this->input->post->get('order', array(), 'array');

        // Sanitize the input
        JArrayHelper::toInteger($pks);
        JArrayHelper::toInteger($order);

        // Save the ordering
        $return = $this->oModelMvc->saveorder($pks, $order);

        if ($return) {
            echo "1";
        }

        // Close the application
        JFactory::getApplication()->close();
    }

}
